package org.ch00.test04.demo07.demo3;

import java.util.Random;

/**
 * 小偷
 * @author CSY
 * @date 2025 - 03 - 04
 */
public class Thief {
    public void steal(Door door) {
        int status = new Random().nextInt(10);
        //判断是否实现接口
        if(door instanceof Ability){
            ((Ability) door).antiTheft();
        }else{
            door.open();
            if(status > 7){
                System.out.println("偷盗成功!");
            }else{
                System.out.println("偷盗失败!");
            }
        }
    }

}
